#ifndef __STD_ERR_H__
#define __STD_ERR_H__

typedef struct _err_map {
	int err;
	const char* name;
	const char* comment;
} err_map_t;

/// 标准错误码
typedef int std_err_t;

#ifdef __cplusplus
extern "C" {
#endif

// 获取错误码对应的错误名称
const char* std_err_name(std_err_t err);
// 获取错误码对应的错误说明
const char* std_err_comment(std_err_t err);

#ifdef __cplusplus
}
#endif

#define STD_ERR_OK                0    	/*!< OK (no error) */
#define STD_ERR_FAIL              -1    /*!< Generic failure */

#if 1
/// 常用标准错误码定义
#define STD_ERR_NO_MEM            -2    /*!< Out of memory */
#define STD_ERR_INVALID_ARG       -3    /*!< Invalid argument */
#define STD_ERR_INVALID_STATE     -4    /*!< Invalid state */
#define STD_ERR_INVALID_SIZE      -5    /*!< Invalid size */
#define STD_ERR_NOT_FOUND         -6    /*!< Requested resource not found */
#define STD_ERR_NOT_SUPPORTED     -7    /*!< Operation or feature not supported */
#define STD_ERR_TIMEOUT           -8    /*!< Operation timed out */
#define STD_ERR_INVALID_RESPONSE  -9  	/*!< Received response was invalid */
#define STD_ERR_INVALID_CRC       -10  	/*!< CRC or checksum was invalid */
#define STD_ERR_INVALID_VERSION   -11   /*!< Version was invalid */
#define STD_ERR_INVALID_MAC       -12  	/*!< MAC address was invalid */

#define STD_ERR_INVALID_IF_TYPE   -13   /*!< Interface type was invalid */
#define STD_ERR_INVALID_SRC_ADDR  -14   /*!< Source address was invalid */
#define STD_ERR_INVALID_DST_ADDR  -15   /*!< Destination address was invalid */
#define STD_ERR_INVALID_FRAME_LEN -16   /*!< Invalid frame length */
#define STD_ERR_INVALID_PARAM_LEN -17   /*!< Invalid parameter length */
#define STD_ERR_BUFFER_OVERFLOW   -18   /*!< Buffer overflow */
#define STD_ERR_BUFFER_UNDERFLOW  -19   /*!< Buffer underflow */
#define STD_ERR_INVALID_COMMAND   -20   /*!< Invalid command */

#define STD_ERR_EOF               -21   /*!< End of file */
#define STD_ERR_UNCLOSED_STRING   -22   /*!< Unclosed string */
#define STD_ERR_ILLEGAL_CHAR      -23   /*!< Illegal character */
#define STD_ERR_TOO_MUCH_CMDPARTS -24   /*!< Too much command parts */
#define STD_ERR_TOO_MUCH_CMDARGS  -25   /*!< Too much command args */
#define STD_ERR_TOO_LARGE_STR     -26   /*!< String is oversize */
#define STD_ERR_OUT_OF_RANGE      -27   /*!< Value is out of range*/
#define STD_ERR_INTERVAL_TIMEOUT  -28   /*!< Timeout in operation interval */
#define STD_ERR_BUFFER_OVERRUN    -29   /*!< Buffer overrun */
#define STD_ERR_EXPIRED           -30   /*!< Resource is expired */
#define STD_ERR_PARTIALLY_EXPIRED -31   /*!< Resource is partially expired */

#define STD_ERR_SYNTAX            -40   ///< Syntax error
#define STD_ERR_NOT_ACCESSIBLE    -41   ///< Resource is not accessible
#define STD_ERR_INVALID_ID        -42   ///< Invalid identifier
#define STD_ERR_DISCONNECTED      -43   ///< Connection is not established
#define STD_ERR_NO_RESOURCES      -44   ///< Out of resources
#define STD_ERR_LOCKED            -45   ///< Resource is locked
#define STD_ERR_NO_LOCK           -46   ///< No lock held
#define STD_ERR_IO                -47   ///< IO error
#define STD_ERR_INVALID_ADDR	  -48   ///< Invalid address
#define STD_ERR_ABORT             -49   ///< Abort
#define STD_ERR_OCCUPIED          -50   ///< Resource is occupied
#define STD_ERR_PROHIBITED        -51   ///< Access is prohibited
#define STD_ERR_CONTINUE          -52   ///< Need more information
#define STD_ERR_RETRY_OUT         -53   ///< Retry times out
#endif

#if USE_XILINX_SDK
//
// Xilinx Vitis SDK ERROR
// from xstatus.h
//
#define XST_SUCCESS                     0L
#define XST_FAILURE                     1L
#define XST_DEVICE_NOT_FOUND            2L
#define XST_DEVICE_BLOCK_NOT_FOUND      3L
#define XST_INVALID_VERSION             4L
#define XST_DEVICE_IS_STARTED           5L
#define XST_DEVICE_IS_STOPPED           6L
#define XST_FIFO_ERROR                  7L	/*!< An error occurred during an operation with a FIFO such as an underrun or overrun, this error requires the device to be reset */
#define XST_RESET_ERROR                 8L	/*!< An error occurred which requires the device to be reset */
#define XST_DMA_ERROR                   9L	/*!< A DMA error occurred, this error typically requires the device using the DMA to be reset */
#define XST_NOT_POLLED                  10L	/*!< The device is not configured for polled mode operation */
#define XST_FIFO_NO_ROOM                11L	/*!< A FIFO did not have room to put the specified data into */
#define XST_BUFFER_TOO_SMALL            12L	/*!< The buffer is not large enough to hold the expected data */
#define XST_NO_DATA                     13L	/*!< There was no data available */
#define XST_REGISTER_ERROR              14L	/*!< A register did not contain the expected value */
#define XST_INVALID_PARAM               15L	/*!< An invalid parameter was passed into the function */
#define XST_NOT_SGDMA                   16L	/*!< The device is not configured for scatter-gather DMA operation */
#define XST_LOOPBACK_ERROR              17L	/*!< A loopback test failed */
#define XST_NO_CALLBACK                 18L	/*!< A callback has not yet been registered */
#define XST_NO_FEATURE                  19L	/*!< Device is not configured with the requested feature */
#define XST_NOT_INTERRUPT               20L	/*!< Device is not configured for interrupt mode operation */
#define XST_DEVICE_BUSY                 21L	/*!< Device is busy */
#define XST_ERROR_COUNT_MAX             22L	/*!< The error counters of a device have maxed out */
#define XST_IS_STARTED                  23L	/*!< Used when part of device is already started i.e. sub channel */
#define XST_IS_STOPPED                  24L	/*!< Used when part of device is already stopped i.e. sub channel */
#define XST_DATA_LOST                   26L	/*!< Driver defined error */
#define XST_RECV_ERROR                  27L	/*!< Generic receive error */
#define XST_SEND_ERROR                  28L	/*!< Generic transmit error */
#define XST_NOT_ENABLED                 29L	/*!< A requested service is not available because it has not been enabled */
#define XST_NO_ACCESS					30L	/* Generic access error */
#define XST_TIMEOUT                     31L	/*!< Event timeout occurred */

#define XST_MEMTEST_FAILED              401L	/*!< Memory test failed */

#define XST_PFIFO_LACK_OF_DATA          501L	/*!< Not enough data in FIFO   */
#define XST_PFIFO_NO_ROOM               502L	/*!< Not enough room in FIFO   */
#define XST_PFIFO_BAD_REG_VALUE         503L	/*!< Self test, a register value was invalid after reset */
#define XST_PFIFO_ERROR                 504L	/*!< Generic packet FIFO error */
#define XST_PFIFO_DEADLOCK              505L	/*!< Packet FIFO is reporting empty and full simultaneously */

#define XST_DMA_TRANSFER_ERROR          511L	/*!< Self test, DMA transfer failed */
#define XST_DMA_RESET_REGISTER_ERROR    512L	/*!< Self test, a register value was invalid after reset */
#define XST_DMA_SG_LIST_EMPTY           513L	/*!< Scatter gather list contains no buffer descriptors ready to be processed */
#define XST_DMA_SG_IS_STARTED           514L	/*!< Scatter gather not stopped */
#define XST_DMA_SG_IS_STOPPED           515L	/*!< Scatter gather not running */
#define XST_DMA_SG_LIST_FULL            517L	/*!< All the buffer descriptors of the scatter gather list are being used */
#define XST_DMA_SG_BD_LOCKED            518L	/*!< The scatter gather buffer descriptor which is to be copied over in the scatter list is locked */
#define XST_DMA_SG_NOTHING_TO_COMMIT    519L	/*!< No buffer descriptors have been put into the scatter gather list to be committed */
#define XST_DMA_SG_COUNT_EXCEEDED       521L	/*!< The packet count threshold specified was larger than the total # of buffer descriptors in the scatter gather list */
#define XST_DMA_SG_LIST_EXISTS          522L	/*!< The scatter gather list has already been created */
#define XST_DMA_SG_NO_LIST              523L	/*!< No scatter gather list has been created */
#define XST_DMA_SG_BD_NOT_COMMITTED     524L	/*!< The buffer descriptor which was being started was not committed to the list */
#define XST_DMA_SG_NO_DATA              525L	/*!< The buffer descriptor to start has already been used by the hardware so it can't be reused */
#define XST_DMA_SG_LIST_ERROR           526L	/*!< General purpose list access error */
#define XST_DMA_BD_ERROR                527L	/*!< General buffer descriptor error */

#define XST_IPIF_REG_WIDTH_ERROR        531L	/*!< An invalid register width was passed into the function */
#define XST_IPIF_RESET_REGISTER_ERROR   532L	/*!< The value of a register at reset was not valid */
#define XST_IPIF_DEVICE_STATUS_ERROR    533L	/*!< A write to the device interrupt status register did not read back correctly */
#define XST_IPIF_DEVICE_ACK_ERROR       534L	/*!< The device interrupt status register did not reset when acked */
#define XST_IPIF_DEVICE_ENABLE_ERROR    535L	/*!< The device interrupt enable register was not updated when other registers changed */
#define XST_IPIF_IP_STATUS_ERROR        536L	/*!< A write to the IP interrupt status register did not read back correctly */
#define XST_IPIF_IP_ACK_ERROR           537L	/*!< The IP interrupt status register did not reset when acked */
#define XST_IPIF_IP_ENABLE_ERROR        538L	/*!< IP interrupt enable register was not updated correctly when other registers changed */
#define XST_IPIF_DEVICE_PENDING_ERROR   539L	/*!< The device interrupt pending register did not indicate the expected value */
#define XST_IPIF_DEVICE_ID_ERROR        540L	/*!< The device interrupt ID register did not indicate the expected value */
#define XST_IPIF_ERROR                  541L	/*!< Generic ipif error */

#define XST_EMAC_MEMORY_SIZE_ERROR  1001L	/*!< Memory space is not big enough to hold the minimum number of buffers or descriptors */
#define XST_EMAC_MEMORY_ALLOC_ERROR 1002L	/*!< Memory allocation failed */
#define XST_EMAC_MII_READ_ERROR     1003L	/*!< MII read error */
#define XST_EMAC_MII_BUSY           1004L	/*!< An MII operation is in progress */
#define XST_EMAC_OUT_OF_BUFFERS     1005L	/*!< Driver is out of buffers */
#define XST_EMAC_PARSE_ERROR        1006L	/*!< Invalid driver init string */
#define XST_EMAC_COLLISION_ERROR    1007L	/*!< Excess deferral or late collision on polled send */

#define XST_UART_INIT_ERROR         1051L
#define XST_UART_START_ERROR        1052L
#define XST_UART_CONFIG_ERROR       1053L
#define XST_UART_TEST_FAIL          1054L
#define XST_UART_BAUD_ERROR         1055L
#define XST_UART_BAUD_RANGE         1056L

#define XST_IIC_SELFTEST_FAILED         1076	/*!< self test failed            */
#define XST_IIC_BUS_BUSY                1077	/*!< bus found busy              */
#define XST_IIC_GENERAL_CALL_ADDRESS    1078	/*!< mastersend attempted with general call address        */
#define XST_IIC_STAND_REG_RESET_ERROR   1079	/*!< A non parameterizable reg value after reset not valid */
#define XST_IIC_TX_FIFO_REG_RESET_ERROR 1080	/*!< Tx fifo included in design value after reset not valid */
#define XST_IIC_RX_FIFO_REG_RESET_ERROR 1081	/*!< Rx fifo included in design value after reset not valid */
#define XST_IIC_TBA_REG_RESET_ERROR     1082	/*!< 10 bit addr incl in design value after reset not valid */
#define XST_IIC_CR_READBACK_ERROR       1083	/*!< Read of the control register didn't return value written */
#define XST_IIC_DTR_READBACK_ERROR      1084	/*!< Read of the data Tx reg didn't return value written */
#define XST_IIC_DRR_READBACK_ERROR      1085	/*!< Read of the data Receive reg didn't return value written */
#define XST_IIC_ADR_READBACK_ERROR      1086	/*!< Read of the data Tx reg didn't return value written */
#define XST_IIC_TBA_READBACK_ERROR      1087	/*!< Read of the 10 bit addr reg didn't return written value */
#define XST_IIC_NOT_SLAVE               1088	/*!< The device isn't a slave    */
#define XST_IIC_ARB_LOST 				1089 	/*!< Arbitration lost for master	*/

#define XST_ATMC_ERROR_COUNT_MAX    1101L	/*!< the error counters in the ATM controller hit the max value which requires the statistics to be cleared */

#define XST_FLASH_BUSY                1126L	/*!< Flash is erasing or programming */
#define XST_FLASH_READY               1127L	/*!< Flash is ready for commands */
#define XST_FLASH_ERROR               1128L	/*!< Flash had detected an internal error. Use XFlash_DeviceControl to retrieve device specific codes */
#define XST_FLASH_ERASE_SUSPENDED     1129L	/*!< Flash is in suspended erase state */
#define XST_FLASH_WRITE_SUSPENDED     1130L	/*!< Flash is in suspended write state */
#define XST_FLASH_PART_NOT_SUPPORTED  1131L	/*!< Flash type not supported by driver */
#define XST_FLASH_NOT_SUPPORTED       1132L	/*!< Operation not supported */
#define XST_FLASH_TOO_MANY_REGIONS    1133L	/*!< Too many erase regions */
#define XST_FLASH_TIMEOUT_ERROR       1134L	/*!< Programming or erase operation aborted due to a timeout */
#define XST_FLASH_ADDRESS_ERROR       1135L	/*!< Accessed flash outside its addressible range */
#define XST_FLASH_ALIGNMENT_ERROR     1136L	/*!< Write alignment error */
#define XST_FLASH_BLOCKING_CALL_ERROR 1137L	/*!< Couldn't return immediately from write/erase function with XFL_NON_BLOCKING_WRITE/ERASE option cleared */
#define XST_FLASH_CFI_QUERY_ERROR     1138L	/*!< Failed to query the device */

#define XST_SPI_MODE_FAULT          1151	/*!< master was selected as slave */
#define XST_SPI_TRANSFER_DONE       1152	/*!< data transfer is complete */
#define XST_SPI_TRANSMIT_UNDERRUN   1153	/*!< slave underruns transmit register */
#define XST_SPI_RECEIVE_OVERRUN     1154	/*!< device overruns receive register */
#define XST_SPI_NO_SLAVE            1155	/*!< no slave has been selected yet */
#define XST_SPI_TOO_MANY_SLAVES     1156	/*!< more than one slave is being selected */
#define XST_SPI_NOT_MASTER          1157	/*!< operation is valid only as master */
#define XST_SPI_SLAVE_ONLY          1158	/*!< device is configured as slave-only */
#define XST_SPI_SLAVE_MODE_FAULT    1159	/*!< slave was selected while disabled */
#define XST_SPI_SLAVE_MODE          1160	/*!< device has been addressed as slave */
#define XST_SPI_RECEIVE_NOT_EMPTY   1161	/*!< device received data in slave mode */

#define XST_SPI_COMMAND_ERROR       1162	/*!< unrecognised command - qspi only */
#define XST_SPI_POLL_DONE           1163    /*!< controller completed polling the device for status */

#define XST_OPBARB_INVALID_PRIORITY  1176	/*!< the priority registers have either one master assigned to two or more priorities, or one master not assigned to any priority */
#define XST_OPBARB_NOT_SUSPENDED     1177	/*!< an attempt was made to modify the priority levels without first suspending the use of priority levels */
#define XST_OPBARB_PARK_NOT_ENABLED  1178	/*!< bus parking by id was enabled but bus parking was not enabled */
#define XST_OPBARB_NOT_FIXED_PRIORITY 1179	/*!< the arbiter must be in fixed priority mode to allow the priorities to be changed */

#define XST_INTC_FAIL_SELFTEST      1201	/*!< self test failed */
#define XST_INTC_CONNECT_ERROR      1202	/*!< interrupt already in use */

#define XST_TMRCTR_TIMER_FAILED     1226	/*!< self test failed */

#define XST_WDTTB_TIMER_FAILED      1251L

#define XST_PLBARB_FAIL_SELFTEST    1276L

#define XST_PLB2OPB_FAIL_SELFTEST   1301L

#define XST_OPB2PLB_FAIL_SELFTEST   1326L

#define XST_SYSACE_NO_LOCK          1351L	/*!< No MPU lock has been granted */

#define XST_PCI_INVALID_ADDRESS     1361L

#define XST_FR_TX_ERROR				1400	/*!< FlexRay TX error */
#define XST_FR_TX_BUSY				1401	/*!< FlexRay TX busy */
#define XST_FR_BUF_LOCKED			1402	/*!< FlexRay buffer locked */
#define XST_FR_NO_BUF				1403	/*!< FlexRay no buffer */

#define XST_USB_ALREADY_CONFIGURED	1410
#define XST_USB_BUF_ALIGN_ERROR		1411
#define XST_USB_NO_DESC_AVAILABLE	1412
#define XST_USB_BUF_TOO_BIG			1413
#define XST_USB_NO_BUF				1414

#define XST_HWICAP_WRITE_DONE		1421

#define XST_VDMA_MISMATCH_ERROR		1430

#define XST_NAND_BUSY				1441L	/*!< Flash is erasing or programming */
#define XST_NAND_READY				1442L	/*!< Flash is ready for commands */
#define XST_NAND_ERROR				1443L	/*!< Flash had detected an internal error */
#define XST_NAND_PART_NOT_SUPPORTED	1444L	/*!< Flash type not supported by driver */
#define XST_NAND_OPT_NOT_SUPPORTED	1445L	/*!< Operation not supported */
#define XST_NAND_TIMEOUT_ERROR		1446L	/*!< Programming or erase operation aborted due to a timeout */
#define XST_NAND_ADDRESS_ERROR		1447L	/*!< Accessed flash outside its addressible range */
#define XST_NAND_ALIGNMENT_ERROR	1448L	/*!< Write alignment error */
#define XST_NAND_PARAM_PAGE_ERROR	1449L	/*!< Failed to read parameter page of the device */
#define XST_NAND_CACHE_ERROR		1450L	/*!< Flash page buffer error */

#define XST_NAND_WRITE_PROTECTED	1451L	/*!< Flash is write protected */
#endif //USE_FREERTOS


#if USE_FREERTOS
//
// errno for FreeRTOS+ components
// from projdefs.h
//
/* The following errno values are used by FreeRTOS+ components, not FreeRTOS itself. */
#define pdFREERTOS_ERRNO_NONE			0	/* No errors */
#define	pdFREERTOS_ERRNO_ENOENT			2	/* No such file or directory */
#define	pdFREERTOS_ERRNO_EINTR			4	/* Interrupted system call */
#define	pdFREERTOS_ERRNO_EIO			5	/* I/O error */
#define	pdFREERTOS_ERRNO_ENXIO			6	/* No such device or address */
#define	pdFREERTOS_ERRNO_EBADF			9	/* Bad file number */
#define	pdFREERTOS_ERRNO_EAGAIN			11	/* No more processes */
#define	pdFREERTOS_ERRNO_EWOULDBLOCK	11	/* Operation would block */
#define	pdFREERTOS_ERRNO_ENOMEM			12	/* Not enough memory */
#define	pdFREERTOS_ERRNO_EACCES			13	/* Permission denied */
#define	pdFREERTOS_ERRNO_EFAULT			14	/* Bad address */
#define	pdFREERTOS_ERRNO_EBUSY			16	/* Mount device busy */
#define	pdFREERTOS_ERRNO_EEXIST			17	/* File exists */
#define	pdFREERTOS_ERRNO_EXDEV			18	/* Cross-device link */
#define	pdFREERTOS_ERRNO_ENODEV			19	/* No such device */
#define	pdFREERTOS_ERRNO_ENOTDIR		20	/* Not a directory */
#define	pdFREERTOS_ERRNO_EISDIR			21	/* Is a directory */
#define	pdFREERTOS_ERRNO_EINVAL			22	/* Invalid argument */
#define	pdFREERTOS_ERRNO_ENOSPC			28	/* No space left on device */
#define	pdFREERTOS_ERRNO_ESPIPE			29	/* Illegal seek */
#define	pdFREERTOS_ERRNO_EROFS			30	/* Read only file system */
#define	pdFREERTOS_ERRNO_EUNATCH		42	/* Protocol driver not attached */
#define	pdFREERTOS_ERRNO_EBADE			50	/* Invalid exchange */
#define	pdFREERTOS_ERRNO_EFTYPE			79	/* Inappropriate file type or format */
#define	pdFREERTOS_ERRNO_ENMFILE		89	/* No more files */
#define	pdFREERTOS_ERRNO_ENOTEMPTY		90	/* Directory not empty */
#define	pdFREERTOS_ERRNO_ENAMETOOLONG 	91	/* File or path name too long */
#define	pdFREERTOS_ERRNO_EOPNOTSUPP		95	/* Operation not supported on transport endpoint */
#define	pdFREERTOS_ERRNO_ENOBUFS		105	/* No buffer space available */
#define	pdFREERTOS_ERRNO_ENOPROTOOPT	109	/* Protocol not available */
#define	pdFREERTOS_ERRNO_EADDRINUSE		112	/* Address already in use */
#define	pdFREERTOS_ERRNO_ETIMEDOUT		116	/* Connection timed out */
#define	pdFREERTOS_ERRNO_EINPROGRESS	119	/* Connection already in progress */
#define	pdFREERTOS_ERRNO_EALREADY		120	/* Socket already connected */
#define	pdFREERTOS_ERRNO_EADDRNOTAVAIL 	125	/* Address not available */
#define	pdFREERTOS_ERRNO_EISCONN		127	/* Socket is already connected */
#define	pdFREERTOS_ERRNO_ENOTCONN		128	/* Socket is not connected */
#define	pdFREERTOS_ERRNO_ENOMEDIUM		135	/* No medium inserted */
#define	pdFREERTOS_ERRNO_EILSEQ			138	/* An invalid UTF-16 sequence was encountered. */
#define	pdFREERTOS_ERRNO_ECANCELED		140	/* Operation canceled. */
#endif //USE_FREERTOS


#if USE_LWIP
//
// LwIP errno
// from lwip/errno.h
//
#define  EPERM            1  /* Operation not permitted */
#define  ENOENT           2  /* No such file or directory */
#define  ESRCH            3  /* No such process */
#define  EINTR            4  /* Interrupted system call */
#define  EIO              5  /* I/O error */
#define  ENXIO            6  /* No such device or address */
#define  E2BIG            7  /* Arg list too long */
#define  ENOEXEC          8  /* Exec format error */
#define  EBADF            9  /* Bad file number */
#define  ECHILD          10  /* No child processes */
#define  EAGAIN          11  /* Try again */
#define  ENOMEM          12  /* Out of memory */
#define  EACCES          13  /* Permission denied */
#define  EFAULT          14  /* Bad address */
#define  ENOTBLK         15  /* Block device required */
#define  EBUSY           16  /* Device or resource busy */
#define  EEXIST          17  /* File exists */
#define  EXDEV           18  /* Cross-device link */
#define  ENODEV          19  /* No such device */
#define  ENOTDIR         20  /* Not a directory */
#define  EISDIR          21  /* Is a directory */
#define  EINVAL          22  /* Invalid argument */
#define  ENFILE          23  /* File table overflow */
#define  EMFILE          24  /* Too many open files */
#define  ENOTTY          25  /* Not a typewriter */
#define  ETXTBSY         26  /* Text file busy */
#define  EFBIG           27  /* File too large */
#define  ENOSPC          28  /* No space left on device */
#define  ESPIPE          29  /* Illegal seek */
#define  EROFS           30  /* Read-only file system */
#define  EMLINK          31  /* Too many links */
#define  EPIPE           32  /* Broken pipe */
#define  EDOM            33  /* Math argument out of domain of func */
#define  ERANGE          34  /* Math result not representable */
#define  EDEADLK         35  /* Resource deadlock would occur */
#define  ENAMETOOLONG    36  /* File name too long */
#define  ENOLCK          37  /* No record locks available */
#define  ENOSYS          38  /* Function not implemented */
#define  ENOTEMPTY       39  /* Directory not empty */
#define  ELOOP           40  /* Too many symbolic links encountered */
#define  EWOULDBLOCK     EAGAIN  /* Operation would block */
#define  ENOMSG          42  /* No message of desired type */
#define  EIDRM           43  /* Identifier removed */
#define  ECHRNG          44  /* Channel number out of range */
#define  EL2NSYNC        45  /* Level 2 not synchronized */
#define  EL3HLT          46  /* Level 3 halted */
#define  EL3RST          47  /* Level 3 reset */
#define  ELNRNG          48  /* Link number out of range */
#define  EUNATCH         49  /* Protocol driver not attached */
#define  ENOCSI          50  /* No CSI structure available */
#define  EL2HLT          51  /* Level 2 halted */
#define  EBADE           52  /* Invalid exchange */
#define  EBADR           53  /* Invalid request descriptor */
#define  EXFULL          54  /* Exchange full */
#define  ENOANO          55  /* No anode */
#define  EBADRQC         56  /* Invalid request code */
#define  EBADSLT         57  /* Invalid slot */

#define  EDEADLOCK       EDEADLK

#define  EBFONT          59  /* Bad font file format */
#define  ENOSTR          60  /* Device not a stream */
#define  ENODATA         61  /* No data available */
#define  ETIME           62  /* Timer expired */
#define  ENOSR           63  /* Out of streams resources */
#define  ENONET          64  /* Machine is not on the network */
#define  ENOPKG          65  /* Package not installed */
#define  EREMOTE         66  /* Object is remote */
#define  ENOLINK         67  /* Link has been severed */
#define  EADV            68  /* Advertise error */
#define  ESRMNT          69  /* Srmount error */
#define  ECOMM           70  /* Communication error on send */
#define  EPROTO          71  /* Protocol error */
#define  EMULTIHOP       72  /* Multihop attempted */
#define  EDOTDOT         73  /* RFS specific error */
#define  EBADMSG         74  /* Not a data message */
#define  EOVERFLOW       75  /* Value too large for defined data type */
#define  ENOTUNIQ        76  /* Name not unique on network */
#define  EBADFD          77  /* File descriptor in bad state */
#define  EREMCHG         78  /* Remote address changed */
#define  ELIBACC         79  /* Can not access a needed shared library */
#define  ELIBBAD         80  /* Accessing a corrupted shared library */
#define  ELIBSCN         81  /* .lib section in a.out corrupted */
#define  ELIBMAX         82  /* Attempting to link in too many shared libraries */
#define  ELIBEXEC        83  /* Cannot exec a shared library directly */
#define  EILSEQ          84  /* Illegal byte sequence */
#define  ERESTART        85  /* Interrupted system call should be restarted */
#define  ESTRPIPE        86  /* Streams pipe error */
#define  EUSERS          87  /* Too many users */
#define  ENOTSOCK        88  /* Socket operation on non-socket */
#define  EDESTADDRREQ    89  /* Destination address required */
#define  EMSGSIZE        90  /* Message too long */
#define  EPROTOTYPE      91  /* Protocol wrong type for socket */
#define  ENOPROTOOPT     92  /* Protocol not available */
#define  EPROTONOSUPPORT 93  /* Protocol not supported */
#define  ESOCKTNOSUPPORT 94  /* Socket type not supported */
#define  EOPNOTSUPP      95  /* Operation not supported on transport endpoint */
#define  EPFNOSUPPORT    96  /* Protocol family not supported */
#define  EAFNOSUPPORT    97  /* Address family not supported by protocol */
#define  EADDRINUSE      98  /* Address already in use */
#define  EADDRNOTAVAIL   99  /* Cannot assign requested address */
#define  ENETDOWN       100  /* Network is down */
#define  ENETUNREACH    101  /* Network is unreachable */
#define  ENETRESET      102  /* Network dropped connection because of reset */
#define  ECONNABORTED   103  /* Software caused connection abort */
#define  ECONNRESET     104  /* Connection reset by peer */
#define  ENOBUFS        105  /* No buffer space available */
#define  EISCONN        106  /* Transport endpoint is already connected */
#define  ENOTCONN       107  /* Transport endpoint is not connected */
#define  ESHUTDOWN      108  /* Cannot send after transport endpoint shutdown */
#define  ETOOMANYREFS   109  /* Too many references: cannot splice */
#define  ETIMEDOUT      110  /* Connection timed out */
#define  ECONNREFUSED   111  /* Connection refused */
#define  EHOSTDOWN      112  /* Host is down */
#define  EHOSTUNREACH   113  /* No route to host */
#define  EALREADY       114  /* Operation already in progress */
#define  EINPROGRESS    115  /* Operation now in progress */
#define  ESTALE         116  /* Stale NFS file handle */
#define  EUCLEAN        117  /* Structure needs cleaning */
#define  ENOTNAM        118  /* Not a XENIX named type file */
#define  ENAVAIL        119  /* No XENIX semaphores available */
#define  EISNAM         120  /* Is a named type file */
#define  EREMOTEIO      121  /* Remote I/O error */
#define  EDQUOT         122  /* Quota exceeded */

#define  ENOMEDIUM      123  /* No medium found */
#define  EMEDIUMTYPE    124  /* Wrong medium type */
/*
typedef enum {
  ERR_OK         = 0,		// 0,            "Ok.",
  ERR_MEM        = -1,		// ENOMEM,       "Out of memory error.",
  ERR_BUF        = -2,		// ENOBUFS,      "Buffer error.",
  ERR_TIMEOUT    = -3,		// EWOULDBLOCK,  "Timeout.",
  ERR_RTE        = -4,		// EHOSTUNREACH, "Routing problem.",
  ERR_INPROGRESS = -5,		// EINPROGRESS,  "Operation in progress.",
  ERR_VAL        = -6,		// EINVAL,       "Illegal value.",
  ERR_WOULDBLOCK = -7,		// EWOULDBLOCK,  "Operation would block.",
  ERR_USE        = -8,		// EADDRINUSE,   "Address in use.",
  ERR_ALREADY    = -9,		// EALREADY,     "Already connecting.",
  ERR_ISCONN     = -10,		// EISCONN,      "Already connected.",
  ERR_CONN       = -11,		// ENOTCONN,     "Not connected.",
  ERR_IF         = -12,		// -1,           "Low-level netif error.",
  ERR_ABRT       = -13,		// ECONNABORTED, "Connection aborted.",
  ERR_RST        = -14,		// ECONNRESET,   "Connection reset.",
  ERR_CLSD       = -15,		// ENOTCONN,     "Connection closed.",
  ERR_ARG        = -16		// EIO           "Illegal argument."
} err_enum_t;
*/
#endif //USE_LWIP

#endif // __STD_ERR_H__
